package com.choosefine.it.company.controller;

import com.choosefine.it.base.BaseController;
import com.choosefine.it.basedata.service.CompanyInfoService;
import com.choosefine.it.common.def.ResultCode;
import com.choosefine.it.common.utils.StringUtils;
import com.choosefine.it.project.model.ProjectManageInfo;
import com.choosefine.it.project.service.ProjectManageService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import javax.validation.constraints.Pattern;


/**
 * 建筑公司—项目管理
 *
 * @author Administrator
 */
@RestController
@RequestMapping("/companyProjectManage")
@Api(value = "建筑公司—项目管理", description = "毛俊")
public class CompanyProjectManageController extends BaseController {
    @Autowired
    ProjectManageService projectManageService;

    @ApiOperation(value = "建筑公司—项目管理-根据承建单位租户编号查看项目", notes = "金额相关参数未处理", response = ProjectManageInfo.class)
    @ApiImplicitParam(name = "userCode", value = "承建单位租户编号", required = true, dataType = "String", paramType = "path")
    @RequestMapping(value = "/getListByConstructUsercode/{userCode}", method = RequestMethod.GET)
    public String getListByConstructUsercode(@PathVariable  String userCode) {
        String result = null;
        if (!StringUtils.isEmpty(userCode)) {
            List<ProjectManageInfo> list = projectManageService.getListByConstructUsercode(userCode);
            if (list.size() > 0) {
                result = responseArraySuccess(list, ResultCode.SUCCESS, ResultCode.MSG_SUCCESS);
            } else {
                result = responseFail(ResultCode.FAILED, ResultCode.MSG_PARAMS_ERROR);
            }
        } else {
            result = responseFail(ResultCode.FAILED, ResultCode.MSG_PARAMS_NULL);
        }
        return result;
    }

}
